/**
 * @Date: Mar 8, 2010 8:07:06 PM
 */
package com.philip.journal.home.controller.action;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;

import com.philip.journal.core.controller.ResponseHandler;
import com.philip.journal.core.service.ServiceProxy;

/**
 * @author cry30
 */
public class NodePropertyAction extends AbstractTreeAction {

    /**
     * Default delegate constructor.
     *
     * @param serviceProxy Service proxy to be injected by Spring.
     * @param responseHandler Response handler to be injected by Spring.
     */
    public NodePropertyAction(final ServiceProxy serviceProxy, final ResponseHandler responseHandler) {
        super(serviceProxy, responseHandler);
    }

    @Override
    public void execute() throws ServletException, IOException
    {
        final String nodeIdParam = getHttpServletRequest().getParameter(NODE_ID);
        final long nodeId = parseId(nodeIdParam);
        final Map<String, Object> nodeProps = getServiceProxy().getNodeProperties(nodeId, nodeIdParam.startsWith("l-"));
        getResponseHandler().respondSuccess(getHttpServletResponse(), nodeProps);
    }
}
